<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // Symbol可以创建一个唯一的属性名 防止被覆盖
    var obj = {
      a:100,
      aaa:400
    }
    var a = 200
    function fn(){
      console.log(this.a)
    }
    // obj.fn = fn
    // obj.fn()




    Function.prototype.mycall = function(object){
      var fnName = Symbol()
      // this ---> fn
      object[fnName] = this
      return obj[fnName]()
    }
    fn.mycall(obj)




    // var arr = [1,2,3]
    // var arr1 = [2,3,4]
    // Array.prototype.sum = function(){
    //   var total = 0
    //   this.forEach(item=>{
    //     total += item
    //   })
    //   return total
    // }
    // console.log(arr.sum())//6
    // arr1.sum()//9
</script>
</body>
</html>
